<template>
	<view>
		<view class="fenlei_title">
			<view class="fenlei_h"><b>*</b>作业分类：</view>
			<view class="fenlei_is_css" @click="acti_click1">{{fenlei_is1?fenlei_is1:'请选择作业分类'}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm1($event)" ref="activity_is1" :options="worktype"></w-picker>
		</view>
		
		<view class="fenlei_title" v-if="stype == 'kc'">
			<view class="fenlei_h"><b>*</b>思政分类：</view>
			<view class="fenlei_is_css" @click="acti_click101">{{fenlei_is101?fenlei_is101:'请选择思政分类'}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm101($event)" ref="activity_is101" :options="conte"></w-picker>
		</view>

		<view class="fenlei_title">
			<view class="fenlei_h"><b>*</b>{{kecheng_title}}：</view>
			<view class="fenlei_is_css" @click="acti_click2">{{fenlei_is2?fenlei_is2:'请选择'+kecheng_title}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm2($event)" ref="activity_is2" :options="kc_list"></w-picker>
		</view>
		<view class="fenlei_title">
			<view class="fenlei_h"><b>*</b>{{zhangjie_title}}：</view>
			<view class="fenlei_is_css" @click="acti_click3">{{fenlei_is3?fenlei_is3:'请选择'+zhangjie_title}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm3($event)" ref="activity_is3" :options="mindType_list"></w-picker>
		</view>

		<view class="fenlei_title" v-if="second_level">
			<view class="fenlei_h"><b>*</b>章节：</view>
			<view class="fenlei_is_css" @click="acti_click4">{{fenlei_is4?fenlei_is4:'请选择节'}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm4($event)" ref="activity_is4" :options="second_list"></w-picker>
		</view>

		<view class="fenlei_title" v-if="third_level">
			<view class="fenlei_h"><b>*</b>小节：</view>
			<view class="fenlei_is_css" @click="acti_click5">{{fenlei_is5?fenlei_is5:'请选择小节'}}</view>
			<w-picker mode="selector" :default-props="activity_type" default-type="name"
				@confirm="onTypeConfirm5($event)" ref="activity_is5" :options="third_list"></w-picker>
		</view>

		<view class="flex">
			<view class="but_css" @click="showSelectVisableBox" type="danger">选题</view>
			<view class="but_css" @click="showSelectVisableBox" type="danger">浏览</view>
		</view>

		<view class="guding_cheng" v-if="homeworkBrowserVisable">
			<view class="guding_close" @click="homeworkBrowserVisable = false">X</view>
			<view class="exam-list">
				<view class="exam-item" v-for="(item, index) in exam_list" :key="index">
					<checkbox :checked="item.checked" @click="duoxuan_is(index)" />
					<view style="display: flex;">
						<view style="width: 58px;text-align: right;">{{ index + 1 }} .</view>
						<view style="padding-left: 20px;">
							<view v-if="item.type == 1">(单选题)</view>
							<view v-if="item.type == 2">(多选题)</view>
							<view v-if="item.type == 3">(判断题)</view>
							{{ item.title }}
						</view>
					</view>
					<view class="exam-item-options w100">
						<view style="width: 75px;align-self: flex-start;" class="exam-item-title">
							<view>选项:</view>
						</view>
						<view class="w100">
							<view class="exam-item-option" v-for="(option, index) in item.choose" :key="index">
								<view style="text-align: center;">{{ xuanxiang[index] }}:</view>
								<view>{{ option }}</view>
							</view>
						</view>
					</view>
					<view class="exam-item-answers w100">
						<view class="exam-item-title">答案:</view>
						<view style="display: flex; align-items: center;font-size: 16px; font-weight: bold;">
							<view v-if="item.type == 1">
								<view v-for="ite in item.answer" :key="ite">{{ xuanxiang[ite - 1] }}</view>
							</view>
							<view v-if="item.type == 2">
								<view v-for="ite in item.answer" :key="ite">{{ xuanxiang[ite - 1] }}</view>
							</view>
							<view v-if="item.type == 3">
								<view v-if="item.answer[0] == 2">√</view>
								<view v-if="item.answer[0] == 1">×</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<view slot="footer" class="dialog-footer">
			<view type="primary" v-if="homeworkBrowserVisable" @click="homeworkBrowserVisable = false">关闭</view>
		</view>

		<view class="qizhi_time">
			<view class="error_validator">起止时间</view>
			<uni-datetime-picker type="daterange" @change="timeChange" />
		</view>
		<view>
			<view class="fenlei_title">
				<view class="fenlei_h">院系：</view>
				<view class="fenlei_is_css" @click="acti_click01">{{fenlei_is01?fenlei_is01:'请选择院系'}}</view>
				<w-picker mode="selector" :default-props="activity_type" default-type="name"
					@confirm="onTypeConfirm01($event)" ref="activity_is01" :options="depaList2"></w-picker>
			</view>

			<view class="fenlei_title">
				<view class="fenlei_h">专业：</view>
				<view class="fenlei_is_css" @click="acti_click02">{{fenlei_is02?fenlei_is02:'请选择专业'}}</view>
				<w-picker mode="selector" :default-props="activity_type" default-type="name"
					@confirm="onTypeConfirm02($event)" ref="activity_is02" :options="profList2"></w-picker>
			</view>

			<view class="fenlei_title">
				<view class="fenlei_h">级别：</view>
				<view class="fenlei_is_css" @click="acti_click03">{{fenlei_is03?fenlei_is03:'请选择级别'}}</view>
				<w-picker mode="selector" :default-props="activity_type" default-type="name"
					@confirm="onTypeConfirm03($event)" ref="activity_is03" :options="gradeList2"></w-picker>
			</view>

			<view class="qizhi_time">
				<view style="height:15px;" v-if="clazzList.length > 0"></view>
				<checkbox  @click="checkAllClazz" v-if="quanxuan==0 && clazzList.length > 0">全选</checkbox>
				<checkbox  @click="checkAllClazz2" v-if="quanxuan==1">全选</checkbox>
				<view style="margin: 15px 0;" v-if="clazzList.length > 0"></view>
				<checkbox-group class="flex">
					<label v-for="(option, index) in clazzList" :key="index">
						<checkbox :checked="option.checked" @click="duoxuan(index)" />{{ option.name }}
					</label>
				</checkbox-group>
			</view>
		</view>
		<view class="qizhi_time">
			<view class="fenlei_zuoye">作业说明:</view>
			<textarea class="shuoming_css" v-model="remark" placeholder="请输入作业说明" />
		</view>
		<view @click="homeworkIssued" class="but_css" type="primary">作业下发</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				quanxuan:0,
				fenlei_is101: '',
				fenlei_is1: '',
				fenlei_is2: '',
				fenlei_is3: '',
				fenlei_is4: '',
				fenlei_is5: '',

				fenlei_is01: '',
				fenlei_is02: '',
				fenlei_is03: '',
				fenlei_is04: '',
				fenlei_is05: '',
				activity_type: {
					"label": "name",
					"value": "id"
				},
				form: {
					class: [],
					date: {}
				},
				worktype: [{
					id: 0,
					name: '思政课程',
				}, {
					id: 1,
					name: '精神谱系',
				}, {
					id: 2,
					name: '全景思政',
				}, {
					id: 3,
					name: 'VR仿真',
				}],
				options: [{
						value: "1",
						label: "班级1"
					},
					{
						value: "2",
						label: "班级2"
					},
					{
						value: "3",
						label: "班级3"
					},
					{
						value: "4",
						label: "班级4"
					},
					{
						value: "5",
						label: "班级5"
					},
					{
						value: "6",
						label: "班级6"
					},
					{
						value: "7",
						label: "班级7"
					},
					{
						value: "8",
						label: "班级8"
					},
				],
				homeworkBrowserVisable: false,
				homeworkBrowserSelectVisable: false, // 题库选题

				depaList2: [],
				selectedDepa2: "",
				selectedProf2: "",
				selectedGrade2: "", // 选中的年级
				selectedClazz2: "", // 选中的班级

				profList2: [], // 教师的专业列表
				gradeList2: [], // 教师的级别列表
				clazzList2: [], // 班级列表
				clazzList: [], // 班级列表

				checkedClazzList: [],
				isIndeterminate: false,

				kc_list: [],
				chapter_list: [],
				second_level: false,
				sizheng_list: false,
				second_list: [],
				third_level: false,
				third_list: [],

				mindType_list: [],
				exam_list: [],

				mindClazzId: "",
				firstChapter: "",
				secondChapter: "",
				thirdChapter: "",
				exam_test_list: [],
				xuanxiang: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H'],

				checkWorkList: [],

				pageNo: 1,
				pageSize: 10,

				borwser_list: [],
				kecheng_title:'课程名称',
				zhangjie_title:'章节选择',

				type: 1,
				startTime: null,
				endTime: null,
				remark: "",
				stype: '',
				mindTypeId: "",
				mindId: "",
				voviId: "",
				vrId: "",
				viqaId: "",
				vrleiId: "",
				cate_inner_list: [],
				conte: []
			};
		},
		created() {
			this.getAllDepaList();
		},
		methods: {
			acti_click101() {
				this.$refs.activity_is101.show();
			},
			onTypeConfirm101(val) {
				this.fenlei_is101 = val.result
				// this.type_name = val.value
				this.getMindClazzList(val.value);
			},
			acti_click1() {
				this.$refs.activity_is1.show();
			},
			onTypeConfirm1(val) {
				this.fenlei_is1 = val.result
				if (val.value == 0) {
					this.kecheng_title = '课程名称'
					this.zhangjie_title = '章节选择'
					this.stype = 'kc'
					this.kc_list = []
					this.second_level = false;
					this.second_list = [];
					this.chapter_list = [];
					this.third_list = [];
					this.third_level = false;
					this.sizheng_list = true;
					this.getSizhengType();

				} else if (val.value == 1) {
					this.kecheng_title = '主题分类'
					this.zhangjie_title = '主题名称'
					this.stype = 'ca'
					this.kc_list = []
					this.getmind()
				} else if (val.value == 2) {
					this.kecheng_title = '全景分类'
					this.zhangjie_title = '全景名称'
					this.stype = 'qa'
					this.quanjing()
					this.kc_list = []
				} else if (val.value == 3) {
					this.kecheng_title = '仿真分类'
					this.zhangjie_title = '仿真名称'
					this.stype = 'vr'
					this.vr_list()
					this.kc_list = []

				}
				// this.type_name = val.value
			},
			acti_click2() {
				this.$refs.activity_is2.show();
			},
			//课程
			onTypeConfirm2(val) {
				this.fenlei_is2 = val.result
				if (this.stype == 'kc') {
					this.mindClazzId = val.value
					this.second_list = []
					this.handleChange()
				} else if (this.stype == 'ca') {
					this.second_list = []
					this.mindTypeId = val.value
					this.getMindByType()
				} else if (this.stype == 'qa') {
					this.viqaId = val.value
					this.second_list = []
					this.quanjing_list(val.value)
				} else if (this.stype == 'vr') {
					this.vrleiId = val.value
					this.second_list = []
					this.vr_list_li(val.value)
				}

			},
			acti_click3() {
				this.$refs.activity_is3.show();

			},
			onTypeConfirm3(val) {
				this.fenlei_is3 = val.result
				if (this.stype == 'kc') {
					this.mindType_list = []
					this.firstChapter = val.value
					this.chapterChange(val.value)
				} else if (this.stype == 'ca') {
					this.mindType_list = []
					this.mindId = val.value
					this.mindIdHandleChange()
				} else if (this.stype == 'qa') {
					this.mindType_list = []
					this.voviId = val.value
					this.mindId = val.value
					this.getVoviDetail(val.value)
				} else if (this.stype == 'vr') {
					this.mindType_list = []
					this.vrId = val.value
					this.mindId = val.value
					this.getVrDetail(val.value)
				}

				// this.type_name = val.value
			},
			acti_click4() {
				this.$refs.activity_is4.show();
			},
			onTypeConfirm4(val) {
				this.fenlei_is4 = val.result
				// this.type_name = val.value
			},
			acti_click5() {
				this.$refs.activity_is5.show();
			},
			onTypeConfirm5(val) {
				this.fenlei_is5 = val.result
				// this.type_name = val.value
			},

			//院系班级
			acti_click01() {
				this.$refs.activity_is01.show();
			},
			onTypeConfirm01(val) {
				this.fenlei_is01 = val.result
				this.selectedDepa2 = val.result
				this.selectDepa2(val.result)
			},
			acti_click02() {
				this.$refs.activity_is02.show();
			},
			//专业
			onTypeConfirm02(val) {
				this.fenlei_is02 = val.result
				this.selectedProf2 = val.result
				this.selectProf2(val.result)
			},
			acti_click03() {
				this.$refs.activity_is03.show();

			},
			onTypeConfirm03(val) {
				this.fenlei_is03 = val.result
				this.selectedGrade2 = val.result
				this.selectGrade2(val.result)
			},
			acti_click04() {
				this.$refs.activity_is04.show();
			},
			onTypeConfirm04(val) {
				this.fenlei_is04 = val.result
				this.selectedClazz2 = val.value
				this.selectClazz2()
			},
			//获取课程分类
			getSizhengType() { 
				let that = this;
				that.pyReq(that.$http.getClazzType,{},function(res){
					  console.log('获取课程分类res', res)
					  res.result.forEach((item, index) => {
					  	that.conte.push({
					  		'name': item.name,
					  		'id': item.id,
					  	})
					  });
				});
			},

			//vr
			vr_list() {
				this.pyReq(this.$http.getVrTypeInfo, {}, (res) => {
					if (res.code == 0) {
						if (res.result && res.result.length !== 0) {
							res.result.forEach((item, index) => {
								this.kc_list.push({
									'name': item.name,
									'id': item.id,
								})
							});
						}
					}
				});
			},
			//vr
			vr_list_li(vrid) {
				let id = vrid
				let pageNo = 1
				let pageSize = 99999

				this.pyReq(this.$http.getVRListByType, {
					id,
					pageNo,
					pageSize
				}, (res) => {
					if (res.code == 0) {
						if (res.result && res.result.length !== 0) {
							console.log('[]', res.result)
							res.result.forEach((item, index) => {
								this.mindType_list.push({
									'name': item.name,
									'id': item.id,
								})
							});
						}
					}
				});
			},
			getVrDetail(vrId) {
				var that = this
				that.pyReq(that.$http.getVrDetail, {
					vrId: vrId
				}, function(res) {
					if (!res.result.testPreview) {
						res.result.testPreview = 0
					} else {
						res.result.testPreview.map((item, index) => {
							item['checked'] = true
							item['type'] = item['testType']
						})
					}
					that.exam_list = res.result.testPreview
				});
			},
			//全景思政
			quanjing() {
				this.pyReq(this.$http.getVoviTypeInfo, {}, (res) => {
					if (res.code == 0) {
						if (res.result && res.result.length !== 0) {
							res.result.forEach((item, index) => {
								this.kc_list.push({
									'name': item.name,
									'id': item.id,
								})
							});
						}
					}
				});
			},
			quanjing_list(vid) {
				let id = vid
				this.pyReq(this.$http.getVoviByType, {
					id
				}, (res) => {
					if (res.code == 0) {
						if (res.result && res.result.length !== 0) {
							res.result.forEach((item, index) => {
								this.mindType_list.push({
									'name': item.name,
									'id': item.id,
								})
							});
						}
					}
				});
			},
			getVoviDetail(voviId) {
				var that = this
				that.pyReq(that.$http.getVoviDetail, {
					voviId: voviId
				}, function(res) {
					console.log('that.content', res.result)
					if (res.result.testPreview) {
						res.result.testPreview.map((item, index) => {
							item['checked'] = true
							item['type'] = item['testType']
						})
					} else {
						res.result.testPreview = 0
					}
					that.exam_list = res.result.testPreview
				});
			},
			clearExamList() {
				this.exam_list = [];
				this.firstChapter = "";
				this.second_level = "";
				this.form.date = {};
				this.checkWorkList = [];
				this.mindClazzId = "";
				this.mindTypeId = "";
				this.mindId = "";
				this.secondChapter = "";
				this.thirdChapter = "";
				this.second_level = false;
				this.third_level = false;
			},
			getMindByType() {
				this.mindId = "";
				this.mindType_list = [];
				const {
					mindTypeId
				} = this;
				console.log('[[]]', mindTypeId)
				if (!mindTypeId) return;
				this.pyReq(this.$http.getMindByType, {
					mindTypeId,
					pageNo: 1,
					pageSize: 9999
				}, (res) => {
					if (res.code == 0) {
						console.log('[[[]]]', res);
						if (res.result && res.result.records.length !== 0) {
							res.result.records.forEach((item, index) => {
								this.mindType_list.push({
									'name': item.mindName,
									'id': item.mindId,
								})
							});
						}
					}
				});
			},
			getmind() {
				this.pyReq(this.$http.getMindType, {
					pageNo: 1,
					pageSize: 9999
				}, (res) => {
					if (res.code == 0) {
						if (res.result && res.result.records.length !== 0) {
							res.result.records.forEach((item, index) => {
								this.kc_list.push({
									'name': item.mindTypeName,
									'id': item.mindTypeId,
								})
							});
						}
					}
				});
			},
			mindIdHandleChange() {

				this.getTestDetailByClazz();
			},
			thirdChapterChange() {
				this.getTestDetailByClazz();
			},
			// / 下发作业
			homeworkIssued() {
				
				this.clazzList.map((item, index)=> {
					console.log('this.clazzList',item) 
					if(item.checked == true){
						this.checkedClazzList.push(item.id)
					}
				});
				if (this.checkedClazzList.length === 0) {
					return uni.showToast({
						title:'请选择班级'
					})
				}
				this.exam_list.map((item, index)=> {
					if(item.checked == true){
						this.checkWorkList.push(item.id)
					}
				});
				if (this.checkWorkList.length === 0) {
					return uni.showToast({
						title:'请选择试题'
					})
				}

				if (this.startTime && this.endTime && this.checkWorkList.length != 0 && this.checkedClazzList.length != 0) {

					var classIds = this.checkedClazzList.map(item => "##" + item).join("") + "##";
					var testIds = this.checkWorkList.map(item => "##" + item).join("") + "##";

					var chapterId = chapterId;
					if (this.stype == 'kc') {
						var type = 1
						var typeId = this.thirdChapter || this.secondChapter || this.firstChapter;
					}else if(this.stype == 'ca'){
						var type = 2
						var typeId = this.mindId
					}else if(this.stype == 'qa'){
						var type = 3
						var typeId = this.voviId
					}else if(this.stype == 'vr'){
						var type = 4
						var typeId = this.vrId
					}
					

					this.pyReq(
						this.$http.commitWork, {
							type: type,
							typeId: typeId,
							startTime: this.startTime,
							endTime: this.endTime,
							classIds: classIds,
							remark: this.remark,
							testIds: testIds
						},
						(res) => {
							if (res.code == 0) {
								this.stype = "kc";
								this.form.date = {};
								this.checkedClazzList = [];
								this.checkWorkList = [];
								this.remark = "";
								this.mindClazzId = "";
								this.mindTypeId = "";
								this.mindId = "";
								this.firstChapter = "";
								this.secondChapter = "";
								this.thirdChapter = "";
								this.second_level = false;
								this.third_level = false;
								this.selectedDepa2 = "";
								this.selectedProf2 = "";
								this.selectedGrade2 = "";
								this.isIndeterminate = false;
								this.clazzList = [];
								this.fenlei_is1 = "";
								this.fenlei_is2 = "";
								this.fenlei_is3 = "";
								this.fenlei_is4 = "";
								this.fenlei_is01 = "";
								this.fenlei_is02 = "";
								this.fenlei_is03 = "";
								this.fenlei_is04 = "";
							}
						}
					);
				} else {
					return uni.showToast({
						title:'请检查必填项'
					})
				}


			},
			timeChange(time) {
				this.startTime = this.dateFormat(time[0]);
				this.endTime = this.dateFormat(time[1]);
				
			},
			getMindClazzList(id) {
				this.pyReq(this.$http.getMindClazzListByType, {
					pageNo:1,
					pageSize:15,
					typeId:id
				}, (res) => {
					console.log('res',res)
					if (res.code == 0) {
						if (res.result && res.result.length !== 0) {
							res.result.forEach((item, index) => {
								this.kc_list.push({
									'name': item.name,
									'id': item.id,
								})
							});

						}
					}
				});

			},

			// 获取教师选择的年级2
			getAllGradeList2(depa, prof) {
				let that = this;
				that.pyReq(
					that.$http.getAllGradeList, {
						depa: depa,
						prof: prof
					},
					(res) => {
						console.log('----', res.result)
						res.result.forEach((item, index) => {
							that.gradeList2.push({
								'name': item,
								'id': index,
							})
						});
					}
				);
			},

			handleChange() {
				this.second_level = false;
				this.second_list = [];
				this.secondChapter = "";
				this.firstChapter = "";
				this.chapter_list = [];
				this.third_list = [];
				this.third_level = false;
				this.thirdChapter = "";
				this.getFirstChapter();
			},
			secondChapterChange(chapterId) {
				this.getTestDetailByClazz();
				const arr = this.second_list.filter(item => item.id == chapterId);
				if (arr.length != 0 && arr[0].isEnd == 0) {
					this.third_level = true;
				} else if (arr.length != 0 && arr[0].isEnd == 1) {
					// this.getTestDetailByClazz();
					return this.third_level = false;
				}

				this.pyReq(
					this.$http.getChildChapter, {
						chapterId
					},
					(res) => {
						this.third_list = res.result;
					}
				);
			},

			chapterChange(chapterId) {
				this.second_level = false;
				this.third_level = false;

				this.getTestDetailByClazz();
				const arr = this.second_list
				console.log("arr", arr)
				if (arr.length != 0 && arr[0].isEnd == 0) {
					this.second_level = true;
				} else if (arr.length != 0 && arr[0].isEnd == 1) {
					// this.getAllTestByClazz(chapterId);
					return (this.second_level = false);
				}
				this.pyReq(this.$http.getChildChapter, {
					chapterId
				}, (res) => {
					res.result.forEach((item, index) => {
						this.second_list.push({
							'name': item.chapterName,
							'id': item.id,
							'isEnd': item.isEnd,
						})
					});
				});
			},
			getFirstChapter() {
				this.mindType_list = []
				const {
					mindClazzId
				} = this;
				if (!mindClazzId && mindClazzId != 0) return uni.showToast({
					title: '请选择课程！'
				});
				this.pyReq(this.$http.getFirstChapter, {
					mindClazzId
				}, (res) => {
					res.result.forEach((item, index) => {
						this.mindType_list.push({
							'name': item.chapterName,
							'id': item.chapterId,
							'isEnd': item.isEnd,
						})
					});
				});
			},

			getTestDetailByClazz() {
				const {
					pageNo,
					pageSize,
					mindId
				} = this;
				if (this.stype == 'kc') {
					var chapterId = null;
					chapterId = this.thirdChapter || this.secondChapter || this.firstChapter;
					console.log('chapterId', chapterId)
					this.pyReq(
						this.$http.getAllTestByClazz, {
							pageNo: 1,
							pageSize: 9999,
							chapterId,
						},
						(res) => {
							if (res.code == 0) {
								console.log('res:', !res.result, res);
								if (!res.result) {
									this.exam_list = [];
									uni.showToast({
										title: '暂时未上传测试题！'
									})
									return;

								}
								
								this.checkWorkList = (res.result.records || []).map(item => item.id);
								res.result.records.map((item, index) => {
									item['checked'] = true
									item['type'] = item['testType']
								})
								this.exam_list = res.result.records;
								
								this.error_message = "";
							} else if (res.code == 400) {
								return uni.showToast({
									title: res.msg
								})
							}
						}
					);
				} else if (this.stype == 'ca') {
					this.pyReq(
						this.$http.getAllTestByMind, {
							pageNo: 1,
							pageSize: 9999,
							mindId
						},
						(res) => {
							if (res.code == 0) {
								if (!res.result) 
								return uni.showToast({
									title: '此课程暂未上传试题'
								})
								this.checkWorkList = res.result.records.map(item => item.id);
								res.result.records.map((item, index) => {
									item['checked'] = true
									item['type'] = item['testType']
								})
								this.exam_list = res.result.records;
								if (fn) fn();
							} else if (res.code == 400) {
								return uni.showToast({
									title: res.msg
								})
							}
						});
				} else if (this.stype == 'qa') {
					this.getVoviDetail(mindId)
					
				} else if (this.stype == 'vr') {
					this.getVrDetail(mindId)
				}
			},

			showSelectVisableBox() {
				const {
					mindTypeId,
					mindId,
					mindClazzId,
					firstChapter,
					second_level,
					secondChapter
				} = this;
				if (this.stype == 'kc') {
					if (!mindClazzId) {
						return uni.showToast({
							title: '请选择课程分类'
						})
					} else if (!firstChapter) {
						return uni.showToast({
							title: '请选择章节/名称!!'
						})
					}
				} else if (this.stype == 'ca') {
					if (!this.mindTypeId) {
						return uni.showToast({
							title: '请选择课程分类'
						})
					}
					if (!this.mindId) {
						return uni.showToast({
							title: '请选择章节/名称'
						})
					}
				}else if (this.stype == 'qa') {
					if (!this.viqaId) {
						return uni.showToast({
							title: '请选择课程分类'
						})
					}
					if (!this.voviId) {
						return uni.showToast({
							title: '请选择章节/名称!'
						})
					}
				}else if (this.stype == 'vr') {
					if (!this.vrId) {
						return uni.showToast({
							title: '请选择课程分类'
						})
					}
					if (!this.vrleiId) {
						return uni.showToast({
							title: '请选择章节/名称！！'
						})
					}
				}
				this.homeworkBrowserVisable = true;
				// 获取 试题 方法 后 展示弹窗 显示对应的题目列表
				this.getTestDetailByClazz();
			},

			// 根据教师和专业列出所有班级
			getAllClazzList(depa, prof, grade) {
				let that = this;
				that.pyReq(
					that.$http.getAllClazzList, {
						depa: depa,
						prof: prof,
						grade: grade
					},
					(res) => {
						console.log('res',res)
						res.result.forEach((item, index) => {
							that.clazzList.push({
								'name': item.clazzName,
								'id': item.clazzId,
								'checked':false
							})
						});
					}
				);
			},
			// 获取所有院系
			getAllDepaList() {
				let that = this;
				that.pyReq(that.$http.getAllDepaList, {}, (res) => {
					res.result.forEach((item, index) => {
						that.depaList2.push({
							'name': item,
							'id': index,
						})
					});
				});
			},

			// 选择院系2
			selectDepa2(val) {
				let that = this;
				that.selectedProf2 = "";
				that.selectedGrade2 = "";
				that.selectedClazz2 = "";
				// that.checkedClazzList=[];//选中的班级
				that.clazzList2 = []; // 班级列表
				if (val == "选课") {
					that.fenlei_is01 = "选课";
					that.fenlei_is02 = "选课";
					that.fenlei_is03 = "选课";

					that.profList2[0] = "选课";
					that.selectedProf2 = "选课";
					that.selectedGrade2 = "选课";
					that.profList2 = [];
					that.gradeList2 = [];
					this.getAllClazzList2("选课", "选课", "");
				} else {
					that.getAllProfList2(that.selectedDepa2);
					this.getAllClazzList2(
						this.selectedDepa2,
						this.selectedProf2,
						this.selectedGrade2
					);
				}
			},
			// 选择专业2
			selectProf2(val) {
				this.getAllClazzList2(
					this.selectedDepa2,
					this.selectedProf2,
					this.selectedGrade2
				);
				this.getAllGradeList2(this.selectedDepa2, this.selectedProf2);
				this.selectedGrade = "";
			},
			// 选择年级2
			selectGrade2(val) {
				this.getAllClazzList(
					this.selectedDepa2,
					this.selectedProf2,
					this.selectedGrade2
				);
			},

			// 获取教师班级的专业2
			getAllProfList2(depa) {
				let that = this;
				that.pyReq(that.$http.getAllProfList, {
					depa: depa
				}, (res) => {
					console.log('---', res)
					res.result.forEach((item, index) => {
						that.profList2.push({
							'name': item,
							'id': index,
						})
					});
				});
			},

			// 根据教师和专业列出所有班级2
			getAllClazzList2(depa, prof, grade) {
				let that = this;
				that.pyReq(
					that.$http.getAllClazzList, {
						depa: depa,
						prof: prof,
						grade: grade
					},
					(res) => {
						res.result.forEach((item, index) => {
							that.clazzList2.push({
								'name': item.clazzName,
								'id': item.classId,
							})
						});
					}
				);
			},
			duoxuan_is(index){
				if(this.exam_list[index].checked){
					this.exam_list[index].checked = false
				}else{
					this.exam_list[index].checked = true
				}
				console.log('this.exam_list',this.exam_list)
			},
			duoxuan(index){
				if(this.clazzList[index].checked){
					this.clazzList[index].checked = false
				}else{
					this.clazzList[index].checked = true
				}
			},
			// 班级全选
			checkAllClazz() {
				this.clazzList.forEach(function(item, index) {
					item.checked = true
				});
				this.quanxuan = 1
				// this.checkedClazzList = val ? clazzList : [];
			},
			// 班级全不选
			checkAllClazz2() {
				this.clazzList.forEach(function(item, index) {
					item.checked = false
				});
				this.quanxuan = 0
				// this.checkedClazzList = val ? clazzList : [];
			},

			dateFormat(time) {
				let date = new Date(time);
				let year = date.getFullYear();
				// 在日期格式中，月份是从0开始的，因此要加0，使用三元表达式在小于10的前面加0，以达到格式统一  如 09:11:05
				let month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
				let day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
				let hours = date.getHours() < 10 ? "0" + date.getHours() : date.getHours();
				let minutes = date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes();
				let seconds = date.getSeconds() < 10 ? "0" + date.getSeconds() : date.getSeconds();
				// 拼接
				return year + "-" + month + "-" + day + " " + hours + ":" + minutes + ":" + seconds;
			},
		}
	};
</script>

<style lang="scss" scoped>
	.shuoming_css{
		border: 1px solid #ddd;
		border-radius: 7px;
		padding: 5px;
		height: 100px;
		width: 97%;
	}
	.fenlei_zuoye{
		font-size: 15px;
		font-weight: bold;
	}
	.guding_close {
		position: fixed;
		right: 15px;
		top: 55px;
		text-align: center;
		font-size: 18px;
		padding: 8px;
		color: #B31610;
		background: #ddd;
		border: 1px solid #B31610;
		border-radius: 7px;
		width: 30px;
		height: 30px;
	}

	.guding_cheng {
		width: 96%;
		height: 600px;
		position: fixed;
		top: 0;
		left: 0;
		background: #fff;
		padding: 2%;
		overflow-y: scroll;
		padding-bottom: 20px;
		z-index: 9;
	}

	.qizhi_time {
		width: 97%;
		margin: 10px auto;
	}

	.flex {
		display: flex;
		flex-wrap: wrap;
	}

	.list_end_css {
		border: 1px solid #B31610;
		border-radius: 7px;
		margin: 5px;
		padding: 8px;
	}

	.but_css {
		background-color: rgb(166, 14, 10);
		margin: 10px auto;
		width: 100px;
		border-radius: 7px;
		color: #fff;
		line-height: 30px;
		text-align: center;
		font-size: 15px;
	}

	.shangchuan_css {
		background-color: rgb(166, 14, 10);
		margin: 10px auto;
		width: 100px;
		border-radius: 7px;
		color: #fff;
		line-height: 30px;
		text-align: center;
		font-size: 15px;
	}

	.xuanze_css {
		width: auto;
		flex: 1;
		border: 1px solid #ddd;
		padding-left: 5px;
		height: 30px;
	}

	.radio_css {
		margin: 10px;
	}

	/deep/.uni-checkbox-input-checked {
		color: #B31610;
		border-color: #B31610 !important;
	}

	/deep/.uni-checkbox-input-checked::before {
		color: #B31610;
	}
	
	/deep/.uni-radio-input-checked {
		color: #B31610;
		background-color: #B31610 !important;
		border-color: #B31610 !important;
	}
	
	/deep/.uni-radio-input-checked::before {
		background-color: #B31610;
		color: #B31610;
	}

	.timu_css {
		line-height: 30px;
		font-size: 15px;
	}

	.timu_css_sed {
		display: flex;
		justify-content: space-between;
	}

	.timu_css_sed input {
		border: 1px solid #ddd;
		border-radius: 7px;
		width: 80%;
		padding-left: 5px;
		height: 30px;
	}

	.fenlei_title {
		padding: 0 5px;
		display: flex;
		justify-content: space-between;
	}

	.fenlei_h {
		font-size: 15px;
		line-height: 25px;
		margin-top: 5px;
		text-align: center;
	}

	.fenlei_h b {
		color: #B31610;
	}

	.fenlei_is_css {
		overflow: hidden;
		width: 72%;
		line-height: 25px;
		border: 1px solid #ddd;
		border-radius: 7px;
		padding-left: 5px;
		margin-top: 5px;
		height: 27px;
	}

	.exam-container {
		border: 1px solid #eee;
		border-radius: 10px;
		padding: 5px;
		width: 90%;
		margin: 5px auto;
	}

	.exam-list {
		text-align: left;
	}

	.exam-item {
		margin-bottom: 30px;


	}

	.exam-item-options,
	.exam-item-answers {
		display: flex;
		align-items: center;
	}

	.exam-item-answers {
		margin-top: 10px;
	}

	.exam-item-option {
		flex: 1;
		display: flex;
		align-items: center;
		font-size: 16px;
		font-weight: bold;
		margin-bottom: 10px;
	}

	.exam-item-title {
		font-weight: bolder;
		font-size: 16px;
	}

	.exam-checkbox-group {
		display: flex;
		align-items: center;
	}

	.exam-checkbox {
		margin-right: 30px;
		width: 50px;


	}

	.el-checkbox__label {
		padding: 0;
	}

	.exam-radio-group {
		margin-left: -10px;
		display: flex;
		align-items: center;
	}

	.exam-radio {
		margin-right: 30px;
		width: 50px;
	}
</style>
